<script>
	import {checkUpdateVersion} from './utils/index';
	export default {
		globalData: {
            iconSize : 16,
        },
        onLaunch(option){
            var userToken=uni.getStorageSync('userToken')    //获取用户的token值，用户判断用户是否登陆过小程序
		
            var _this=this;
            uni.hideTabBar();
            // _this.getUserInfo();
            
            uni.getSystemInfo({
                success: res => {
                    console.log(res)
                    let windowHeight = res.windowHeight;
                    let contentVideoheight = res.windowWidth*0.8*(9/16);
                    let CapsuleStyle = uni.getMenuButtonBoundingClientRect();
                    //导航栏高度
                    let navigationbarHeight = CapsuleStyle.height + (CapsuleStyle.top - res.statusBarHeight)*2 + res.statusBarHeight;
                    //除去胶囊体，导航栏可以空间
                    let TopNavStyle = {
                        width: CapsuleStyle.left,
                        height: navigationbarHeight - res.statusBarHeight
                    }
                    let navStyle = {
                        safeArea : res.statusBarHeight, //状态栏高度
                        navigationbarHeight: navigationbarHeight, //导航栏高度
                        CapsuleStyle: CapsuleStyle, //胶囊体位置信息
                        TopNavStyle: TopNavStyle, //除去胶囊体，导航栏可以空间
                        windowHeight: windowHeight, //页面内容高度
                        contentVideoHeight: contentVideoheight //视频高度
                    }
                    _this.$options.globalData.navStyle = navStyle;
                    // let windowWidth = res.windowWidth;
                    // if (windowWidth>480){
                    //     // getApp().globalData.iconSize = 48
                    //     _this.$options.globalData.iconSize = 48;
                    // }
                }
            })
            if (userToken) {
                this.getUserInfo();
            }
		},
        onLoad(){
            // console.log("window.location");
        },
        onShow(){
			checkUpdateVersion();
			setTimeout(()=>{
				this.saveHistory()
			},2000)
			console.log(this.$options.globalData)
        },
        methods:{
            async getUserInfo(){
                //获取用户信息
                let userToken=uni.getStorageSync('userToken')
                let res=await this.$api.getUserInfo({user_token:userToken});
                if(res.data.level=='success'){
                    uni.setStorageSync("userId",res.data.data.id);
                }
            },
			saveHistory(){
				let pageInfo=getCurrentPages()[0];
				this.$bus.$data.historyUrl={
					path:pageInfo.route,
					options:pageInfo.options
				}
			}
        }
	}
</script>

<style>
	/*每个页面公共css */
	@import url("/components/gaoyia-parse/parse.css");
	.list-content-text .wxParse {
		line-height: 32rpx !important;
		min-height: 36rpx;
	}
</style>
